<?php
/**
 * @author Inhere
 * @version v1.0
 * Use :  Contents List
 * file : ContentsList.php
 * Date : 2014-4-10
 */
namespace ulue\ext\zui;

use ulue\libs\front\Element;
use ulue\libs\front\Html;
use ulue\web;

class ContentsList extends web\Widget
{
    /**
     * 用户是否登录，用于判断是否显示编辑/删除操作按钮
     */
    public $isLogin   = false;

    /**
     * 显示缩略图
     */
    public $showThumb = false;

    /**
     * 内容
     * @var string
     */
    public $content;

    /**
     * 使列表更紧凑，去掉两边padding
     */
    public $condensed = false;

    /**
     * 显示摘要
     */
    public $abstract = false;

    public $labels = [
        [
            'content' => '原创',
            'class' => 'label label-info'
        ],
        [
            'content' => '火爆',
            'class' => 'label label-warning'
        ],
        [
            'content' => '<i class="icon-eye-open"></i> 234',
            'class' => 'label label-danger'
        ]
    ];

    public $enableError = true;

    public function beginExecute()
    {
        return $this->render('content_view', [
            'labelStr' => $this->getLabelStr(),
            ]);
    }

    protected function getLabelStr()
    {
        $string = '';

        if ($labels = $this->labels) {

            foreach ($labels as $label) {
                $string .= Html::tag('span', null, $label);
            }
        }

        return $string;
    }
}